'''
Descripttion: 
version: 
Author: dylan.Ding
Date: 2020-12-20 14:43:05
LastEditors: Please set LastEditors
LastEditTime: 2020-12-28 15:15:12
'''

import configparser
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from utils.utils import changeBiosFormat

class config(object):
    def __init__(self):
        base_dir = str(os.path.dirname(os.path.dirname(__file__)))
        base_dir = base_dir.replace('\\', '/')
        file_path = base_dir + "/config/conf.ini"
        print("read from: " + file_path)
        # class configparser to read config file
        self.cf = configparser.ConfigParser()
        self.cf.read(file_path)

    def getConfig(self, sections, key, mode='str'):
        try:
            if mode == 'int':
                value = self.cf.getint(sections, key)
            elif mode == 'str':
                value = self.cf.get(sections, key)
            elif mode == 'float':
                value = self.cf.getfloat(sections, key)
            return value
        except Exception as ex:
            print(ex)


if __name__ == "__main__":
    cf = config()
    # print(changeBiosFormat(cf.getConfig("bios", "initial_bios", mode='str')))

    # action1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    # action2 = [0, 0, 0, 1, 3, 3, 0, 0, 0]
    # action1 = action2.copy()
    # # action1 = action2
    # action2[1] = 1221
    # # action1[4] = 100
    # print(action1)
    # print(action2)
    print(cf.getConfig('path', 'log_path') + 'run.log')
